package com.youhome.mobile.controller;

import cn.jsms.api.JSMSClient;
import cn.jsms.api.SendSMSResult;
import cn.jsms.api.common.model.SMSPayload;
import com.youhome.common.config.SMSConfig;
import com.youhome.common.exception.CustomException;
import com.youhome.common.response.Result;
import com.youhome.common.response.ResultCode;
import com.youhome.service.service.BUserService;
import com.youhome.service.service.SMSService;
import com.youhome.utils.ValidationUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by chen365 on 2017/7/17.
 */
@Api(tags = "短信")
@RestController
@RequestMapping(value = "/sms")
public class SMSController {

    @Autowired
    private SMSService smsService;

    /**
     * 获取验证短信
     *
     * @param phone 手机号
     * @return
     */
    @ApiOperation(value = "获取短信验证码")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "String", name = "phone", value = "手机号码", required = true, paramType = "path")
    })
    @GetMapping(value = "/{phone}")
    public Object sms(@PathVariable String phone) throws CustomException {
        return new Result(ResultCode.SUCCESS, smsService.getSMSCode(phone));
    }
}
